<template>
	<view>
		<!-- 加载动画组件 -->
		<wlk-loading></wlk-loading>
		<!-- 登录弹窗组件 -->
		<wlk-login></wlk-login>
		<!-- 微信登录弹窗组件 -->
		<wlk-wxLogin></wlk-wxLogin>
		<u-popup :show="show" :round='10' mode='center' :safeAreaInsetBottom='false' @close='show=false'>
			<view class="popup pr p60">
				<image class="liwu" src="https://feiya.qfxwl.com/assets/img/liwu.png" mode="widthFix"></image>
				<view class="rmb pr">
					<image src="https://feiya.qfxwl.com/assets/img/rmb.png" mode="widthFix" class="ww100"></image>
					<view class="d-c-c pos">
						<view class="left mr20 pr20">
							<view class="money fb">{{coupon.sub_price}}</view>
							<view class="f34">{{coupon.name}}</view>
						</view>
						<view class="right">
							<view class="fb">RMB</view>
							<view class="">满减券</view>
						</view>
					</view>
				</view>
				<view class="btn d-c-c" @click="getCoupon">立即领取
					<!-- <u-button text='' shape='circle' color='linear-gradient(to bottom,#fee9ca,#fdac77)'></u-button> -->
				</view>
				<view class="f24 mt40 gray6 line pb20" v-if="coupon.rule">
					<view>使用说明:</view>
					<view class="mt5">{{coupon.rule}}</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	import wlkLoading from "@/components/common/loading"
	import wlkLogin from "@/components/wlk-login/wlk-login.vue"
	import wlkWxLogin from "@/components/wlk-wxLogin/wlk-wxLogin.vue"
	export default {
		components: {
			wlkLoading,
			wlkLogin,
			wlkWxLogin
		},
		computed: {
			...mapState(['coupon']),
		},
		watch: {
			coupon(value) {
				if (value) {
					this.show = true
				} else {
					this.show = false
				}
			}
		},
		created() {
			this.$nextTick(() => {
				// console.log(this.$store.state.coupon);
			})
		},
		data() {
			return {
				show: false
			}
		},
		methods: {
			async getCoupon() {
				console.log(this.coupon)
				if(this.coupon.is_join == 1){
					const res = await uni.$u.http.post('user/receivecoupon', { cid: this.coupon.cid })
					uni.showToast({
						title: res.msg,
						icon:"none"
					})
				} else {
					const res = await uni.$u.http.post('user/receivecoupon', { id: this.coupon.id })
					uni.showToast({
						title: res.msg,
						icon:"none"
					})
				}
				this.show = false
			}
		}
	};
</script>
<style scoped lang="scss">
	::v-deep .popup {
		width: 600rpx;
		background-image: linear-gradient(to bottom, #fff6e7, #fddfab);
		border-radius: 20rpx;

		.rmb {
			border-radius: 30rpx;
			padding: 40rpx;
			width: 500rpx;
			margin: 20rpx auto 0;
			color: #f7744d;

			.pos {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;

				.left {
					border-right: 1px solid;

					.money {
						font-size: 60rpx;
					}
				}


				.right {
					font-size: 40rpx;

					.fb {
						font-size: 54rpx;
					}
				}
			}

		}

		.btn {
			width: 300rpx;
			margin: 0 auto;
			border-radius: 40rpx;
			height: 80rpx;
			color: $-tour-price-color !important;
			font-weight: bold !important;
			font-size: 40rpx !important;
			background-image: linear-gradient(to bottom, #fee9ca, #fdac77);
		}

		.liwu {
			width: 400rpx;
			display: block;
			margin: 0 auto;
			margin-top: -150px;
		}



	}
</style>